package com.ruoyi.web.controller.shop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.MonthIncome;
import com.ruoyi.shop.service.IMonthIncomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 利润月结Controller
 * 
 * @author ruoyi
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/shop/monthIncome")
public class MonthIncomeController extends BaseController
{
    @Autowired
    private IMonthIncomeService monthIncomeService;

    /**
     * 查询利润月结列表
     */
    @PreAuthorize("@ss.hasPermi('shop:monthIncome:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonthIncome monthIncome)
    {
        startPage();
        List<MonthIncome> list = monthIncomeService.selectMonthIncomeList(monthIncome);
        return getDataTable(list);
    }

    @GetMapping("/list2")
    public TableDataInfo list2(MonthIncome monthIncome)
    {
        startPage();
        List<MonthIncome> list2 = monthIncomeService.selectMonthIncomeList2(monthIncome);
        return getDataTable(list2);
    }

    /**
     * 导出利润月结列表
     */
    @PreAuthorize("@ss.hasPermi('shop:monthIncome:export')")
    @Log(title = "利润月结", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonthIncome monthIncome)
    {
        List<MonthIncome> list = monthIncomeService.selectMonthIncomeList(monthIncome);
        ExcelUtil<MonthIncome> util = new ExcelUtil<MonthIncome>(MonthIncome.class);
        util.exportExcel(response, list, "利润月结数据");
    }

    /**
     * 获取利润月结详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:monthIncome:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(monthIncomeService.selectMonthIncomeById(id));
    }

    /**
     * 新增利润月结
     */
    @PreAuthorize("@ss.hasPermi('shop:monthIncome:add')")
    @Log(title = "利润月结", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonthIncome monthIncome)
    {
        return toAjax(monthIncomeService.insertMonthIncome(monthIncome));
    }

    /**
     * 修改利润月结
     */
    @PreAuthorize("@ss.hasPermi('shop:monthIncome:edit')")
    @Log(title = "利润月结", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonthIncome monthIncome)
    {
        return toAjax(monthIncomeService.updateMonthIncome(monthIncome));
    }

    /**
     * 删除利润月结
     */
    @PreAuthorize("@ss.hasPermi('shop:monthIncome:remove')")
    @Log(title = "利润月结", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(monthIncomeService.deleteMonthIncomeByIds(ids));
    }
}
